//
// Created by Administrator on 2019/12/06.
//

#include "FileOpr.h"

void FileOpr::writeContent(const char * path, string content)
{
    ofstream outFile;
    outFile.open(path, ios_base::trunc);
    outFile<<content;
    outFile.close();
}

string FileOpr::readContent(const char *path) {
    ifstream ifs;
    ifs.open(path, ios_base::in);
    char *buffer = new char[100];
    string result;
    try {
        while (!ifs.eof())
        {
            ifs.read(buffer, 100);
            result.append(buffer);
        }
    }catch (...){
    }

    delete[] buffer;
    ifs.close();
    return result;
}
